#!/bin/bash

PARALLEL_DIR='/home/user/usr/parallel/bin'
SPEC_DIR="../dsn24"
LOG_DIR="../parallel_logs"
BYMC_DIR="/home/user/bymc/bymc"

specs=("safety-abraham-byz.ta" "safety-dumbo-byz.ta" "safety-mostefa-byz.ta")
formulas=("agree0" "valid0" "nonblocking")

# Number of available CPU cores
NUM_CORES=$(nproc)  # Get the number of cores dynamically

# Function to process each combination of spec and formula
process_spec_formula() {
    local spec="$1"
    local formula="$2"
    
    timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
    timestamp="${timestamp//[^a-zA-Z0-9_-]/_}" 
    log_file="$LOG_DIR/"$spec"_"$formula"_${timestamp}.log"
    
    # Your command here (replace with actual arguments)
    "$BYMC_DIR"/verify "$SPEC_DIR"/"$spec" "$formula" -O schema.tech=ltl -O schema.incremental=1 >> "$log_file" 2>&1
}

# Run commands in parallel for the specified number of repetitions
for ((i = 1; i <= 3; i++)); do
    "$PARALLEL_DIR"/parallel --jobs "$NUM_CORES" process_spec_formula ::: "${specs[@]}" ::: "${formulas[@]}"
done
